home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / UPDATE- Int&Libs 3.2 / AIncludes / Multiprocessing.a < prev    next >
Encoding:
Text File  |  1999-05-25  |  27.8 KB  |  997 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        Multiprocessing.a
  3. ;
  4. ;    Contains:    Multiprocessing interfaces
  5. ;
  6. ;    Version:    Technology:    Multiprocessing API version 2.0, integrated nanokernel support
  7. ;                Release:    Veronica Seed, Use with 3.2 Universal Interfaces
  8. ;
  9. ;    Copyright:    © 1996-1999 by Apple Computer, Inc. and © 1995-1997 DayStar Digital, Inc.
  10. ;
  11. ;    Bugs?:        For bug reports, consult the following page on
  12. ;                the World Wide Web:
  13. ;
  14. ;                    http://developer.apple.com/bugreporter/
  15. ;
  16. ;
  17.  
  18. ;   ===========================================================================================
  19. ;   *** WARNING: You must properly check the availability of MP services before calling them!
  20. ;   See the section titled "Checking API Availability".
  21. ;   ===========================================================================================
  22.  
  23.  
  24.  
  25.  
  26.     IF &TYPE('__MULTIPROCESSING__') = 'UNDEFINED' THEN
  27. __MULTIPROCESSING__ SET 1
  28.  
  29.     IF &TYPE('__MACTYPES__') = 'UNDEFINED' THEN
  30.     include 'MacTypes.a'
  31.     ENDIF
  32.     IF &TYPE('__CODEFRAGMENTS__') = 'UNDEFINED' THEN
  33.     include 'CodeFragments.a'
  34.     ENDIF
  35.  
  36.     IF &TYPE('__DRIVERSERVICES__') = 'UNDEFINED' THEN
  37.     include 'DriverServices.a'
  38.     ENDIF
  39.  
  40.  
  41.  
  42. ;   ===========================================================================================
  43. ;   This is the header file for version 2.0 of the Mac OS multiprocessing support.  This version
  44. ;   has been totally reimplemented and has significant new services.  The main goal of the
  45. ;   reimplementation has been to transfer task management into the core operating system to provide
  46. ;   much more reliable and more efficient operation, including on single processor machines.
  47. ;   The memory management has also been massively improved, it is much faster and wastes much
  48. ;   less space.  New services include POSIX style per-task storage, timers with millisecond and
  49. ;   microsecond resolutions, memory allocation at a specified alignment, and system pageable
  50. ;   and RAM resident memory pools.  See the MP API documentation for details.
  51. ;   The old "DayStar" debugging services (whose names began with an underscore) have been
  52. ;   removed from this header.  A very few are still implemented for binary compatibility, or in
  53. ;   cases where they happened to be exposed inappropriately.  (E.g. _MPIsFullyInitialized must
  54. ;   be called to see if the MP API is ReallyTruly™ usable.)  New code and recompiles of old
  55. ;   code should avoid use of these defunct services, except for _MPIsFullyInitialized.
  56. ;   ===========================================================================================
  57.  
  58.  
  59.  
  60.  
  61.  
  62. ;   ===========================================================================================
  63. ;   The following services are from the original MP API and remain supported in version 2.0:
  64. ;      MPProcessors
  65. ;      MPCreateTask
  66. ;      MPTerminateTask
  67. ;      MPCurrentTaskID
  68. ;      MPYield
  69. ;      MPExit
  70. ;      MPCreateQueue
  71. ;      MPDeleteQueue
  72. ;      MPNotifyQueue
  73. ;      MPWaitOnQueue
  74. ;      MPCreateSemaphore
  75. ;      MPCreateBinarySemaphore        (In C only, a macro that calls MPCreateSemaphore.)
  76. ;      MPDeleteSemaphore
  77. ;      MPSignalSemaphore
  78. ;      MPWaitOnSemaphore
  79. ;      MPCreateCriticalRegion
  80. ;      MPDeleteCriticalRegion
  81. ;      MPEnterCriticalRegion
  82. ;      MPExitCriticalRegion
  83. ;      MPAllocate                    (Deprecated, use MPAllocateAligned for new builds.)
  84. ;      MPFree
  85. ;      MPBlockCopy
  86. ;      MPLibraryIsLoaded            (In C only, a macro.)
  87. ;      _MPIsFullyInitialized        (See comments about checking for MP API availability.)
  88. ;   ===========================================================================================
  89.  
  90.  
  91.  
  92.  
  93.  
  94. ;   ===========================================================================================
  95. ;   The following services are new in version 2.0:
  96. ;      MPProcessorsScheduled
  97. ;      MPSetTaskWeight
  98. ;      MPTaskIsPreemptive
  99. ;      MPAllocateTaskStorageIndex
  100. ;      MPDeallocateTaskStorageIndex
  101. ;      MPSetTaskStorageValue
  102. ;      MPGetTaskStorageValue
  103. ;      MPSetQueueReserve
  104. ;      MPCreateEvent
  105. ;      MPDeleteEvent
  106. ;      MPSetEvent
  107. ;      MPWaitForEvent
  108. ;      UpTime
  109. ;      DurationToAbsolute
  110. ;      AbsoluteToDuration
  111. ;      MPDelayUntil
  112. ;      MPCreateTimer
  113. ;      MPDeleteTimer
  114. ;      MPSetTimerNotify
  115. ;      MPArmTimer
  116. ;      MPCancelTimer
  117. ;      MPSetExceptionHandler
  118. ;      MPThrowException
  119. ;      MPDisposeTaskException
  120. ;      MPExtractTaskState
  121. ;      MPSetTaskState
  122. ;      MPRegisterDebugger
  123. ;      MPUnregisterDebugger
  124. ;      MPAllocateAligned            (Preferred over MPAllocate.)
  125. ;      MPGetAllocatedBlockSize
  126. ;      MPBlockClear
  127. ;      MPDataToCode
  128. ;      MPRemoteCall                (Preferred over _MPRPC.)
  129. ;   ===========================================================================================
  130.  
  131.  
  132.  
  133.  
  134.  
  135. ;   ===========================================================================================
  136. ;   The following services are "unofficial" extensions to the original API.  They are not in
  137. ;   the multiprocessing API documentation, but were in previous versions of this header.  They
  138. ;   remain supported in version 2.0.  They may not be supported in other environments.
  139. ;      _MPRPC                        (Deprecated, use MPRemoteCall for new builds.)
  140. ;      _MPAllocateSys                (Deprecated, use MPAllocateAligned for new builds.)
  141. ;      _MPTaskIsToolboxSafe
  142. ;      _MPLibraryVersion
  143. ;      _MPLibraryIsCompatible
  144. ;   ===========================================================================================
  145.  
  146.  
  147.  
  148.  
  149.  
  150. ;   ===========================================================================================
  151. ;   The following services were in previous versions of this header for "debugging only" use.
  152. ;   They are NOT implemented in version 2.0.  For old builds they can be accessed by defining
  153. ;   the symbol MPIncludeDefunctServices to have a nonzero value.
  154. ;      _MPInitializePrintf
  155. ;      _MPPrintf
  156. ;      _MPDebugStr
  157. ;      _MPStatusPString
  158. ;      _MPStatusCString
  159. ;   ===========================================================================================
  160.  
  161.  
  162.  
  163.  
  164.  
  165. ;   §
  166. ;   ===========================================================================================
  167. ;   General Types and Constants
  168. ;   ===========================
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175. MPLibrary_MajorVersion            EQU        2
  176. MPLibrary_MinorVersion            EQU        0
  177. MPLibrary_Release                EQU        1
  178. MPLibrary_DevelopmentRevision    EQU        1
  179.  
  180. ; typedef CFragContextID                 MPProcessID
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. kMPNoID                            EQU        0                    ; New code should use kInvalidID everywhere.
  200.  
  201. ; typedef OptionBits                     MPTaskOptions
  202.  
  203. ; typedef UInt32                         TaskStorageIndex
  204.  
  205. ; typedef UInt32                         TaskStorageValue
  206.  
  207. ; typedef ItemCount                     MPSemaphoreCount
  208.  
  209. ; typedef UInt32                         MPTaskWeight
  210.  
  211. ; typedef UInt32                         MPEventFlags
  212.  
  213. ; typedef UInt32                         MPExceptionKind
  214.  
  215. ; typedef UInt32                         MPTaskStateKind
  216.  
  217. ; typedef UInt32                         MPDebuggerLevel
  218.  
  219.  
  220. kDurationImmediate                EQU        0
  221. kDurationForever                EQU        $7FFFFFFF
  222. kDurationMillisecond            EQU        1
  223. kDurationMicrosecond            EQU        -1
  224.  
  225.  
  226. ;   §
  227. ;   ===========================================================================================
  228. ;   Tasking Services
  229. ;   ================
  230.  
  231.  
  232.  
  233.  
  234. ;
  235. ; extern ItemCount MPProcessors(void )
  236. ;
  237.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  238.         IMPORT_CFM_FUNCTION MPProcessors
  239.     ENDIF
  240.  
  241. ;  The physical total.
  242. ;
  243. ; extern ItemCount MPProcessorsScheduled(void )
  244. ;
  245.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  246.         IMPORT_CFM_FUNCTION MPProcessorsScheduled
  247.     ENDIF
  248.  
  249. ;  Those currently in use.
  250. ;  -------------------------------------------------------------------------------------------
  251.  
  252.  
  253. ;
  254. ; extern OSStatus MPCreateTask(TaskProc entryPoint, void *parameter, ByteCount stackSize, MPQueueID notifyQueue, void *terminationParameter1, void *terminationParameter2, MPTaskOptions options, MPTaskID *task)
  255. ;
  256.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  257.         IMPORT_CFM_FUNCTION MPCreateTask
  258.     ENDIF
  259.  
  260. ;
  261. ; extern OSStatus MPTerminateTask(MPTaskID task, OSStatus terminationStatus)
  262. ;
  263.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  264.         IMPORT_CFM_FUNCTION MPTerminateTask
  265.     ENDIF
  266.  
  267. ;
  268. ; extern OSStatus MPSetTaskWeight(MPTaskID task, MPTaskWeight weight)
  269. ;
  270.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  271.         IMPORT_CFM_FUNCTION MPSetTaskWeight
  272.     ENDIF
  273.  
  274. ;
  275. ; extern Boolean MPTaskIsPreemptive(MPTaskID taskID)
  276. ;
  277.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  278.         IMPORT_CFM_FUNCTION MPTaskIsPreemptive
  279.     ENDIF
  280.  
  281. ;  May be kInvalidID.
  282. ;
  283. ; extern void MPExit(OSStatus status)
  284. ;
  285.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  286.         IMPORT_CFM_FUNCTION MPExit
  287.     ENDIF
  288.  
  289. ;
  290. ; extern void MPYield(void )
  291. ;
  292.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  293.         IMPORT_CFM_FUNCTION MPYield
  294.     ENDIF
  295.  
  296. ;
  297. ; extern MPTaskID MPCurrentTaskID(void )
  298. ;
  299.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  300.         IMPORT_CFM_FUNCTION MPCurrentTaskID
  301.     ENDIF
  302.  
  303.  
  304. ;  -------------------------------------------------------------------------------------------
  305.  
  306.  
  307.  
  308. ;   ---------------------------------------------------
  309. ;   ! The task storage services are new in version 2.0.
  310.  
  311.  
  312.  
  313.  
  314. ;
  315. ; extern OSStatus MPAllocateTaskStorageIndex(TaskStorageIndex *index)
  316. ;
  317.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  318.         IMPORT_CFM_FUNCTION MPAllocateTaskStorageIndex
  319.     ENDIF
  320.  
  321. ;
  322. ; extern OSStatus MPDeallocateTaskStorageIndex(TaskStorageIndex index)
  323. ;
  324.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  325.         IMPORT_CFM_FUNCTION MPDeallocateTaskStorageIndex
  326.     ENDIF
  327.  
  328. ;
  329. ; extern OSStatus MPSetTaskStorageValue(TaskStorageIndex index, TaskStorageValue value)
  330. ;
  331.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  332.         IMPORT_CFM_FUNCTION MPSetTaskStorageValue
  333.     ENDIF
  334.  
  335. ;
  336. ; extern TaskStorageValue MPGetTaskStorageValue(TaskStorageIndex index)
  337. ;
  338.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  339.         IMPORT_CFM_FUNCTION MPGetTaskStorageValue
  340.     ENDIF
  341.  
  342.  
  343.  
  344. ;   §
  345. ;   ===========================================================================================
  346. ;   Synchronization Services
  347. ;   ========================
  348.  
  349.  
  350.  
  351.  
  352. ;
  353. ; extern OSStatus MPCreateQueue(MPQueueID *queue)
  354. ;
  355.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  356.         IMPORT_CFM_FUNCTION MPCreateQueue
  357.     ENDIF
  358.  
  359. ;
  360. ; extern OSStatus MPDeleteQueue(MPQueueID queue)
  361. ;
  362.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  363.         IMPORT_CFM_FUNCTION MPDeleteQueue
  364.     ENDIF
  365.  
  366. ;
  367. ; extern OSStatus MPNotifyQueue(MPQueueID queue, void *param1, void *param2, void *param3)
  368. ;
  369.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  370.         IMPORT_CFM_FUNCTION MPNotifyQueue
  371.     ENDIF
  372.  
  373. ;
  374. ; extern OSStatus MPWaitOnQueue(MPQueueID queue, void **param1, void **param2, void **param3, Duration timeout)
  375. ;
  376.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  377.         IMPORT_CFM_FUNCTION MPWaitOnQueue
  378.     ENDIF
  379.  
  380. ;
  381. ; extern OSStatus MPSetQueueReserve(MPQueueID queue, ItemCount count)
  382. ;
  383.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  384.         IMPORT_CFM_FUNCTION MPSetQueueReserve
  385.     ENDIF
  386.  
  387.  
  388. ;  -------------------------------------------------------------------------------------------
  389.  
  390.  
  391. ;
  392. ; extern OSStatus MPCreateSemaphore(MPSemaphoreCount maximumValue, MPSemaphoreCount initialValue, MPSemaphoreID *semaphore)
  393. ;
  394.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  395.         IMPORT_CFM_FUNCTION MPCreateSemaphore
  396.     ENDIF
  397.  
  398. ;
  399. ; extern OSStatus MPDeleteSemaphore(MPSemaphoreID semaphore)
  400. ;
  401.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  402.         IMPORT_CFM_FUNCTION MPDeleteSemaphore
  403.     ENDIF
  404.  
  405. ;
  406. ; extern OSStatus MPSignalSemaphore(MPSemaphoreID semaphore)
  407. ;
  408.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  409.         IMPORT_CFM_FUNCTION MPSignalSemaphore
  410.     ENDIF
  411.  
  412. ;
  413. ; extern OSStatus MPWaitOnSemaphore(MPSemaphoreID semaphore, Duration timeout)
  414. ;
  415.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  416.         IMPORT_CFM_FUNCTION MPWaitOnSemaphore
  417.     ENDIF
  418.  
  419.  
  420.  
  421. ;  -------------------------------------------------------------------------------------------
  422.  
  423.  
  424. ;
  425. ; extern OSStatus MPCreateCriticalRegion(MPCriticalRegionID *criticalRegion)
  426. ;
  427.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  428.         IMPORT_CFM_FUNCTION MPCreateCriticalRegion
  429.     ENDIF
  430.  
  431. ;
  432. ; extern OSStatus MPDeleteCriticalRegion(MPCriticalRegionID criticalRegion)
  433. ;
  434.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  435.         IMPORT_CFM_FUNCTION MPDeleteCriticalRegion
  436.     ENDIF
  437.  
  438. ;
  439. ; extern OSStatus MPEnterCriticalRegion(MPCriticalRegionID criticalRegion, Duration timeout)
  440. ;
  441.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  442.         IMPORT_CFM_FUNCTION MPEnterCriticalRegion
  443.     ENDIF
  444.  
  445. ;
  446. ; extern OSStatus MPExitCriticalRegion(MPCriticalRegionID criticalRegion)
  447. ;
  448.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  449.         IMPORT_CFM_FUNCTION MPExitCriticalRegion
  450.     ENDIF
  451.  
  452.  
  453. ;  -------------------------------------------------------------------------------------------
  454.  
  455.  
  456. ;
  457. ; extern OSStatus MPCreateEvent(MPEventID *event)
  458. ;
  459.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  460.         IMPORT_CFM_FUNCTION MPCreateEvent
  461.     ENDIF
  462.  
  463. ;
  464. ; extern OSStatus MPDeleteEvent(MPEventID event)
  465. ;
  466.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  467.         IMPORT_CFM_FUNCTION MPDeleteEvent
  468.     ENDIF
  469.  
  470. ;
  471. ; extern OSStatus MPSetEvent(MPEventID event, MPEventFlags flags)
  472. ;
  473.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  474.         IMPORT_CFM_FUNCTION MPSetEvent
  475.     ENDIF
  476.  
  477. ;
  478. ; extern OSStatus MPWaitForEvent(MPEventID event, MPEventFlags *flags, Duration timeout)
  479. ;
  480.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  481.         IMPORT_CFM_FUNCTION MPWaitForEvent
  482.     ENDIF
  483.  
  484.  
  485.  
  486. ;   §
  487. ;   ===========================================================================================
  488. ;   Timer Services
  489. ;   ==============
  490.  
  491.  
  492.  
  493.  
  494.  
  495. ;   --------------------------------------------
  496. ;   ! The timer services are new in version 2.0.
  497.  
  498.  
  499.  
  500.  
  501.     IF 0 THEN
  502. ;  For now these are taken from DriverServices, should be in a better place.
  503. ;
  504. ; extern AbsoluteTime UpTime(void )
  505. ;
  506.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  507.         IMPORT_CFM_FUNCTION UpTime
  508.     ENDIF
  509.  
  510. ;
  511. ; extern AbsoluteTime DurationToAbsolute(Duration duration)
  512. ;
  513.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  514.         IMPORT_CFM_FUNCTION DurationToAbsolute
  515.     ENDIF
  516.  
  517. ;
  518. ; extern Duration AbsoluteToDuration(AbsoluteTime time)
  519. ;
  520.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  521.         IMPORT_CFM_FUNCTION AbsoluteToDuration
  522.     ENDIF
  523.  
  524.     ENDIF    ; 0
  525.  
  526.                                                             ; For MPArmTimer options
  527. kMPPreserveTimerIDMask            EQU        $00000001
  528. kMPTimeIsDeltaMask                EQU        $00000002
  529. kMPTimeIsDurationMask            EQU        $00000004
  530.  
  531. ;
  532. ; extern OSStatus MPDelayUntil(AbsoluteTime *expirationTime)
  533. ;
  534.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  535.         IMPORT_CFM_FUNCTION MPDelayUntil
  536.     ENDIF
  537.  
  538. ;
  539. ; extern OSStatus MPCreateTimer(MPTimerID *timerID)
  540. ;
  541.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  542.         IMPORT_CFM_FUNCTION MPCreateTimer
  543.     ENDIF
  544.  
  545. ;
  546. ; extern OSStatus MPDeleteTimer(MPTimerID timerID)
  547. ;
  548.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  549.         IMPORT_CFM_FUNCTION MPDeleteTimer
  550.     ENDIF
  551.  
  552. ;
  553. ; extern OSStatus MPSetTimerNotify(MPTimerID timerID, MPOpaqueID notificationID, void *notifyParam1, void *notifyParam2, void *notifyParam3)
  554. ;
  555.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  556.         IMPORT_CFM_FUNCTION MPSetTimerNotify
  557.     ENDIF
  558.  
  559. ;
  560. ; extern OSStatus MPArmTimer(MPTimerID timerID, AbsoluteTime *expirationTime, OptionBits options)
  561. ;
  562.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  563.         IMPORT_CFM_FUNCTION MPArmTimer
  564.     ENDIF
  565.  
  566. ;
  567. ; extern OSStatus MPCancelTimer(MPTimerID timerID, AbsoluteTime *timeRemaining)
  568. ;
  569.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  570.         IMPORT_CFM_FUNCTION MPCancelTimer
  571.     ENDIF
  572.  
  573.  
  574.  
  575. ;   §
  576. ;   ===========================================================================================
  577. ;   Memory Services
  578. ;   ===============
  579.  
  580.  
  581.  
  582.  
  583.  
  584.                                                             ; Maximum allocation request size is 1GB.
  585. kMPMaxAllocSize                    EQU        1073741824
  586.  
  587.                                                             ; Values for the alignment parameter to MPAllocateAligned.
  588. kMPAllocateDefaultAligned        EQU        0
  589. kMPAllocate8ByteAligned            EQU        3
  590. kMPAllocate16ByteAligned        EQU        4
  591. kMPAllocate32ByteAligned        EQU        5
  592. kMPAllocate1024ByteAligned        EQU        10
  593. kMPAllocate4096ByteAligned        EQU        12
  594. kMPAllocateMaxAlignment            EQU        16                    ; Somewhat arbitrary limit on expectations.
  595. kMPAllocateAltiVecAligned        EQU        4                    ; The P.C. name.
  596. kMPAllocateVMXAligned            EQU        4                    ; The older, common name.
  597. kMPAllocateVMPageAligned        EQU        254                    ; Pseudo value, converted at runtime.
  598. kMPAllocateInterlockAligned        EQU        255                    ; Pseudo value, converted at runtime.
  599.  
  600.                                                             ; Values for the options parameter to MPAllocateAligned.
  601. kMPAllocateClearMask            EQU        $0001                ; Zero the allocated block.
  602. kMPAllocateGloballyMask            EQU        $0002                ; Allocate from the globally visible pool.
  603. kMPAllocateResidentMask            EQU        $0004                ; Allocate from the RAM-resident pool.
  604. kMPAllocateNoGrowthMask            EQU        $0010                ; Do not attempt to grow the pool.
  605.  
  606. ;  -------------------------------------------------------------------------------------------
  607.  
  608.  
  609. ;
  610. ; extern LogicalAddress MPAllocateAligned(ByteCount size, UInt8 alignment, OptionBits options)
  611. ;
  612.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  613.         IMPORT_CFM_FUNCTION MPAllocateAligned
  614.     ENDIF
  615.  
  616. ;  ! MPAllocateAligned is new in version 2.0.
  617. ;
  618. ; extern LogicalAddress MPAllocate(ByteCount size)
  619. ;
  620.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  621.         IMPORT_CFM_FUNCTION MPAllocate
  622.     ENDIF
  623.  
  624. ;  Use MPAllocateAligned instead.
  625. ;
  626. ; extern void MPFree(LogicalAddress object)
  627. ;
  628.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  629.         IMPORT_CFM_FUNCTION MPFree
  630.     ENDIF
  631.  
  632. ;
  633. ; extern ByteCount MPGetAllocatedBlockSize(LogicalAddress object)
  634. ;
  635.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  636.         IMPORT_CFM_FUNCTION MPGetAllocatedBlockSize
  637.     ENDIF
  638.  
  639. ;  -------------------------------------------------------------------------------------------
  640.  
  641.  
  642. ;
  643. ; extern void MPBlockCopy(LogicalAddress source, LogicalAddress destination, ByteCount size)
  644. ;
  645.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  646.         IMPORT_CFM_FUNCTION MPBlockCopy
  647.     ENDIF
  648.  
  649. ;
  650. ; extern void MPBlockClear(LogicalAddress address, ByteCount size)
  651. ;
  652.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  653.         IMPORT_CFM_FUNCTION MPBlockClear
  654.     ENDIF
  655.  
  656. ;  ! MPBlockClear is new in version 2.0.
  657. ;
  658. ; extern void MPDataToCode(LogicalAddress address, ByteCount size)
  659. ;
  660.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  661.         IMPORT_CFM_FUNCTION MPDataToCode
  662.     ENDIF
  663.  
  664. ;  ! MPDataToCode is new in version 2.0.
  665.  
  666. ;   §
  667. ;   ===========================================================================================
  668. ;   Exception/Debugging Services
  669. ;   ============================
  670.  
  671.  
  672.  
  673.  
  674.  
  675. ;   -------------------------------------------------------------------------------------------
  676. ;   *** Important Note ***
  677. ;   ----------------------
  678. ;   
  679. ;   The functions MPExtractTaskState and MPSetTaskState infer the size of the "info" buffer
  680. ;   from the "kind" parameter.  A given value for MPTaskStateKind will always refer to a
  681. ;   single specific physical buffer layout.  Should new register sets be added, or the size
  682. ;   or number of any registers change, new values of MPTaskStateKind will be introduced to
  683. ;   refer to the new buffer layouts.  The types for the buffers are in MachineExceptions.
  684. ;   
  685. ;   The correspondence between MPTaskStateKind values and MachineExceptions types is:
  686. ;   
  687. ;          kMPTaskStateRegisters                -> RegisterInformation
  688. ;          kMPTaskStateFPU                        -> FPUInformation
  689. ;          kMPTaskStateVectors                    -> VectorInformation
  690. ;          kMPTaskStateMachine                    -> MachineInformation
  691. ;          kMPTaskState32BitMemoryException    -> ExceptionInfo for old-style 32-bit memory exceptions
  692. ;   
  693. ;      For reference, on PowerPC the MachineExceptions types contain:
  694. ;   
  695. ;          RegisterInformation    -> The GPRs, 32 values of 64 bits each.
  696. ;          FPUInformation        -> The FPRs plus FPSCR, 32 values of 64 bits each, one value of
  697. ;                                  32 bits.
  698. ;          VectorInformation    -> The AltiVec vector registers plus VSCR and VRSave, 32 values
  699. ;                                  of 128 bits each, one value of 128 bits, and one 32 bit value.
  700. ;          MachineInformation    -> The CTR, LR, PC, each of 64 bits.  The CR, XER, MSR, MQ,
  701. ;                                  exception kind, and DSISR, each of 32 bits.  The 64 bit DAR.
  702. ;          ExceptionInfo        -> Only memory exceptions are specified, 4 fields of 32 bits each.
  703. ;                                  Note that this type only covers memory exceptions on 32-bit CPUs!
  704.  
  705.  
  706.  
  707.  
  708.  
  709.                                                             ; Values for the TaskStateKind to MPExtractTaskState and MPSetTaskState.
  710. kMPTaskStateRegisters            EQU        0                    ; The task general registers.
  711. kMPTaskStateFPU                    EQU        1                    ; The task floating point registers
  712. kMPTaskStateVectors                EQU        2                    ; The task vector registers
  713. kMPTaskStateMachine                EQU        3                    ; The task machine registers
  714. kMPTaskState32BitMemoryException EQU    4                    ; The task memory exception information for 32-bit CPUs.
  715.  
  716.                                                             ; Option bits and numbers for MPDisposeTaskException.
  717. kMPTaskPropagate                EQU        0                    ; The exception is propagated.
  718. kMPTaskResumeStep                EQU        1                    ; The task is resumed and single step is enabled.
  719. kMPTaskResumeBranch                EQU        2                    ; The task is resumed and branch stepping is enabled.
  720. kMPTaskResumeMask                EQU        $0000                ; The task is resumed.
  721. kMPTaskPropagateMask            EQU        $01                    ; The exception is propagated.
  722. kMPTaskResumeStepMask            EQU        $02                    ; The task is resumed and single step is enabled.
  723. kMPTaskResumeBranchMask            EQU        $04                    ; The task is resumed and branch stepping is enabled.
  724.  
  725. ;  -------------------------------------------------------------------------------------------
  726.  
  727. ;
  728. ; extern OSStatus MPSetExceptionHandler(MPTaskID task, MPQueueID exceptionQ)
  729. ;
  730.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  731.         IMPORT_CFM_FUNCTION MPSetExceptionHandler
  732.     ENDIF
  733.  
  734. ;
  735. ; extern OSStatus MPThrowException(MPTaskID task, MPExceptionKind kind)
  736. ;
  737.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  738.         IMPORT_CFM_FUNCTION MPThrowException
  739.     ENDIF
  740.  
  741. ;
  742. ; extern OSStatus MPDisposeTaskException(MPTaskID task, OptionBits action)
  743. ;
  744.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  745.         IMPORT_CFM_FUNCTION MPDisposeTaskException
  746.     ENDIF
  747.  
  748. ;
  749. ; extern OSStatus MPExtractTaskState(MPTaskID task, MPTaskStateKind kind, void *info)
  750. ;
  751.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  752.         IMPORT_CFM_FUNCTION MPExtractTaskState
  753.     ENDIF
  754.  
  755. ;
  756. ; extern OSStatus MPSetTaskState(MPTaskID task, MPTaskStateKind kind, void *info)
  757. ;
  758.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  759.         IMPORT_CFM_FUNCTION MPSetTaskState
  760.     ENDIF
  761.  
  762. ;  -------------------------------------------------------------------------------------------
  763.  
  764. ;
  765. ; extern OSStatus MPRegisterDebugger(MPQueueID queue, MPDebuggerLevel level)
  766. ;
  767.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  768.         IMPORT_CFM_FUNCTION MPRegisterDebugger
  769.     ENDIF
  770.  
  771. ;
  772. ; extern OSStatus MPUnregisterDebugger(MPQueueID queue)
  773. ;
  774.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  775.         IMPORT_CFM_FUNCTION MPUnregisterDebugger
  776.     ENDIF
  777.  
  778.  
  779.  
  780.  
  781.  
  782. ;   §
  783. ;   ===========================================================================================
  784. ;   Remote Call Services
  785. ;   ====================
  786.  
  787.  
  788.  
  789.  
  790. ; typedef UInt8                         MPRemoteContext
  791.  
  792.  
  793. kMPAnyRemoteContext                EQU        0
  794. kMPOwningProcessRemoteContext    EQU        1
  795.  
  796. ;
  797. ; extern void *MPRemoteCall(MPRemoteProcedure remoteProc, void *parameter, MPRemoteContext context)
  798. ;
  799.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  800.         IMPORT_CFM_FUNCTION MPRemoteCall
  801.     ENDIF
  802.  
  803. ;  ! MPRemoteCall is new in version 2.0.
  804.  
  805. ;   §
  806. ;   ===========================================================================================
  807. ;   Checking API Availability
  808. ;   =========================
  809.  
  810.  
  811.  
  812.  
  813.  
  814. ;   ===========================================================================================
  815. ;   *** WARNING: You must properly check the availability of MP services before calling them!
  816. ;   ===========================================================================================
  817. ;   
  818. ;   Checking for the availability of the MP API is rather ugly.  This is a historical problem,
  819. ;   caused by the original implementation letting itself get prepared when it really wasn't
  820. ;   usable and complicated by some important clients then depending on weak linking to "work".
  821. ;   (And further complicated by CFM not supporting "deferred" imports, which is how many
  822. ;   programmers think weak imports work.)
  823. ;   
  824. ;   The end result is that the MP API library may get prepared by CFM but be totally unusable.
  825. ;   This means that if you import from the MP API library, you cannot simply check for a
  826. ;   resolved import to decide if MP services are available.  Worse, if you explicitly prepare
  827. ;   the MP API library you cannot assume that a noErr result from GetSharedLibrary means that
  828. ;   MP services are available.
  829. ;   
  830. ;   • If you import from the MP API library you MUST:
  831. ;   
  832. ;          Use the MPLibraryIsLoaded macro (or equivalent code in languages other than C) to tell
  833. ;          if the MP API services are available.  It is not sufficient to simply check that an
  834. ;          imported symbol is resolved as is commonly done for other libraries.  The macro expands
  835. ;          to the expression:
  836. ;   
  837. ;              ( ( (UInt32)_MPIsFullyInitialized != (UInt32)kUnresolvedCFragSymbolAddress ) &&
  838. ;                ( _MPIsFullyInitialized () ) )
  839. ;   
  840. ;          This checks if the imported symbol _MPIsFullyInitialized is resolved and if resolved
  841. ;          calls it.  Both parts must succeed for the MP API services to be available.
  842. ;   
  843. ;   • If you explicitly prepare the MP API library you MUST:
  844. ;   
  845. ;          Use code similar to the following example to tell if the MP API services are available.
  846. ;          It is not sufficient to depend on just a noErr result from GetSharedLibrary.
  847. ;   
  848. ;              OSErr                        err;
  849. ;              Boolean                        mpIsAvailable            = false;
  850. ;              CFragConnectionID            connID                    = kInvalidID;
  851. ;              MPIsFullyInitializedProc    mpIsFullyInitialized    = NULL;
  852. ;   
  853. ;              err    = GetSharedLibrary    ( "\pMPLibrary", kCompiledCFragArch, kReferenceCFrag,
  854. ;                                        &connID, NULL, NULL );
  855. ;   
  856. ;              if ( err == noErr ) {
  857. ;                  err    = FindSymbol    ( connID, "\p_MPIsFullyInitialized",
  858. ;                                        (Ptr *) &mpIsFullyInitialized, NULL );
  859. ;              }
  860. ;   
  861. ;              if ( err == noErr ) {
  862. ;                  mpIsAvailable = (* mpIsFullyInitialized) ();
  863. ;              }
  864. ;   
  865. ;   ===========================================================================================
  866.  
  867.  
  868.  
  869.  
  870. ;
  871. ; extern Boolean _MPIsFullyInitialized(void )
  872. ;
  873.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  874.         IMPORT_CFM_FUNCTION _MPIsFullyInitialized
  875.     ENDIF
  876.  
  877.  
  878. ;   ===========================================================================================
  879. ;   The MPLibraryIsLoaded service is a macro under C that expands to the logical expression:
  880. ;          ( (UInt32)MPProcessors != (UInt32)kUnresolvedCFragSymbolAddress )
  881. ;   The intention is to check if the imported symbol MPProcessors is resolved.  For other
  882. ;   languages use the equivalent expression.
  883. ;   ===========================================================================================
  884.  
  885.  
  886.  
  887. ;   §
  888. ;   ===========================================================================================
  889. ;   Miscellaneous Services
  890. ;   ======================
  891.  
  892.  
  893.  
  894.  
  895. ;
  896. ; extern void _MPLibraryVersion(const char **versionCString, UInt32 *major, UInt32 *minor, UInt32 *release, UInt32 *revision)
  897. ;
  898.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  899.         IMPORT_CFM_FUNCTION _MPLibraryVersion
  900.     ENDIF
  901.  
  902.  
  903. ;   §
  904. ;   ===========================================================================================
  905. ;   Unofficial Services
  906. ;   ===================
  907.  
  908.  
  909.  
  910.  
  911.  
  912. ;   ===========================================================================================
  913. ;   *** WARNING ***
  914. ;   These services are not part of the officially documented multiprocessing API.  They may not
  915. ;   be avaliable in future versions of Mac OS multiprocessing support, or in environments that
  916. ;   have a different underlying OS architecture such as Mac OS on top of a microkernel, the
  917. ;   Mac OS Blue Box under Mac OS X, native MP support in Mac OS X, etc.
  918. ;   ===========================================================================================
  919.  
  920.  
  921.  
  922.  
  923. ;
  924. ; extern LogicalAddress _MPAllocateSys(ByteCount size)
  925. ;
  926.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  927.         IMPORT_CFM_FUNCTION _MPAllocateSys
  928.     ENDIF
  929.  
  930. ;  Use MPAllocateAligned instead.
  931. ;
  932. ; extern void *_MPRPC(MPRemoteProcedure remoteProc, void *parameter)
  933. ;
  934.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  935.         IMPORT_CFM_FUNCTION _MPRPC
  936.     ENDIF
  937.  
  938. ;  Use _MPRemoteCall instead.
  939. ;
  940. ; extern Boolean _MPTaskIsToolboxSafe(MPTaskID task)
  941. ;
  942.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  943.         IMPORT_CFM_FUNCTION _MPTaskIsToolboxSafe
  944.     ENDIF
  945.  
  946. ;
  947. ; extern Boolean _MPLibraryIsCompatible(const char *versionCString, UInt32 major, UInt32 minor, UInt32 release, UInt32 revision)
  948. ;
  949.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  950.         IMPORT_CFM_FUNCTION _MPLibraryIsCompatible
  951.     ENDIF
  952.  
  953.  
  954.  
  955.  
  956. ;   §
  957. ;   ===========================================================================================
  958. ;   Defunct Services
  959. ;   ================
  960.  
  961.  
  962.  
  963.  
  964.     IF &TYPE('MPIncludeDefunctServices') = 'UNDEFINED' THEN
  965.     MPIncludeDefunctServices: SET 0
  966.     ENDIF
  967.     IF MPIncludeDefunctServices THEN
  968. ;
  969. ; extern void _MPDebugStr(ConstStr255Param msg)
  970. ;
  971.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  972.         IMPORT_CFM_FUNCTION _MPDebugStr
  973.     ENDIF
  974.  
  975. ;
  976. ; extern StringPtr _MPStatusPString(OSStatus status)
  977. ;
  978.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  979.         IMPORT_CFM_FUNCTION _MPStatusPString
  980.     ENDIF
  981.  
  982. ;
  983. ; extern const char *_MPStatusCString(OSStatus status)
  984. ;
  985.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  986.         IMPORT_CFM_FUNCTION _MPStatusCString
  987.     ENDIF
  988.  
  989.  
  990.     ENDIF    ; MPIncludeDefunctServices
  991. ;  ===========================================================================================
  992.  
  993.  
  994.  
  995.     ENDIF ; __MULTIPROCESSING__ 
  996.  
  997.